﻿using Microsoft.Practices.Mobile.Configuration;

namespace ConfigurationGettingStarted
{
    class ApplicationUser : ConfigurationSection
    {
        private const string AttributeProfile = "profile";
        private const string AttributeContact = "contact";

        [ConfigurationProperty(AttributeProfile)]
        public UserProfile Profile
        {
            get { return (UserProfile)this[AttributeProfile]; }
            set { this[AttributeProfile] = value; }
        }

        [ConfigurationProperty(AttributeContact)]
        public UserContact Contact
        {
            get { return (UserContact)this[AttributeContact]; }
            set { this[AttributeContact] = value; }
        }
    }

    class UserProfile : ConfigurationElement
    {
        private const string AttributeName = "name";
        private const string AttributeCompany = "company";
        private const string AttributeAge = "age";

        [ConfigurationProperty(AttributeName)]
        public string Name
        {
            get { return (string)this[AttributeName]; }
            set { this[AttributeName] = value; }
        }

        [ConfigurationProperty(AttributeCompany)]
        public string Company
        {
            get { return (string)this[AttributeCompany]; }
            set { this[AttributeCompany] = value; }
        }

        [ConfigurationProperty(AttributeAge)]
        public int Age
        {
            get { return (int)this[AttributeAge]; }
            set { this[AttributeAge] = value; }
        }
    }


    class UserContact : ConfigurationElement
    {
        private const string AttributePhone = "phone";
        private const string AttributeEmail = "email";

        [ConfigurationProperty(AttributePhone)]
        public string Phone
        {
            get { return (string)this[AttributePhone]; }
            set { this[AttributePhone] = value; }
        }

        [ConfigurationProperty(AttributeEmail)]
        public string Email
        {
            get { return (string)this[AttributeEmail]; }
            set { this[AttributeEmail] = value; }
        }
    }
}
